﻿namespace SEED.SEEDModels {
    using System;
    using System.IO;
    using System.Text;
    using System.Linq;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using SEEDControllers;

    public class SEED {

        public ControlHeader  Header     { get; set; }
        public List<Station>  Stations   { get; set; }
        public TimeSpanConH   TimeSeries { get; set; }
        public List<Waveform> Waveform   { get; set; }
        public string FileName   { get; set; }
        public bool   IsFileOpen { get; set; }
        public int LogicalRecordLenght { get { return Header.LogicalRecordLength; } }
        

        public SEED() {
            this.Header     = new ControlHeader();
            this.Stations   = new List<Station>();
            TimeSeries = new TimeSpanConH();
            Waveform = new List<Waveform>();
            this.FileName   = "";
            this.IsFileOpen = false;
        }
        public SEED(string filePath) {
            this.Header     = new ControlHeader();
            this.Stations   = new List<Station>();
            TimeSeries = new TimeSpanConH();
            Waveform = new List<Waveform>();
            this.FileName   = filePath;
            this.IsFileOpen = false;
            //静态类（全局用），在程序运行之间一直存在
            //如果程序需要在运行期间重新初始化，则必须
            //先将其清空
            if (Helper.LogicalRecordIndentBlocks.Count != 0) {
                Helper.LogicalRecordIndentBlocks.Clear();
            }
            if (Stations.Count != 0) {
                foreach (Station sta in Stations) {
                    if (sta.Channels.Count != 0) {
                        sta.Channels.Clear();
                    }
                }
                Stations.Clear();
            }

            ReadData(filePath);
        }

        private void ReadData(string filePath) {
            FileStream fStream     = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            BinaryReader binReader = new BinaryReader(fStream, Encoding.ASCII);

            ReadHeader(binReader, this.Header);
            ReadStations(binReader, this.Stations);
            ReadTimeSpanConHeader(binReader, this.TimeSeries);
            ReadWaveForm(binReader,this.Waveform);

            binReader.Close();
            fStream.Close();

            this.IsFileOpen = true;
        }

        #region 读取有用头部信息的函数
        private void ReadHeader(BinaryReader binReader, ControlHeader header) {
            // 先读取卷索引控制头段
            ReadVolumeIndex(binReader, header);
            // 之后读取简写字典控制头段
            ReadAbbDict(binReader, header);
        }
        private void ReadVolumeIndex(BinaryReader binReader, ControlHeader header) {
            // 先读取卷标识分区块[010]
            ReadBlock010(binReader, header);
            // 之后接着读取台站索引分区块[011]
            ReadBlock011(binReader, header);
            // 最后读取卷时间片索引分区块[012]
            ReadBlock012(binReader, header);
        }
        private void ReadBlock010(BinaryReader binReader, ControlHeader header) {
            // 由于本分区块是第一个逻辑记录的第一个分区块，而本分区块的最大长度只有239个字节,
            // 根据SEED规定,逻辑记录最小长度为256字节,239 + 8 < 256[逻辑记录标识块本身占8字节]
            // 所以不要担心本逻辑记录无法存储完本分区块内容,也就不必进行逻辑判断
            Helper.SetLogicalRecordIndentBlock(binReader);
            //跳过不需要的信息[块类型、块长度]
            binReader.BaseStream.Position += 7;
            // 格式版本
            header.Version = float.Parse(new string(binReader.ReadChars(4)));
            // 逻辑记录长度
            header.LogicalRecordLength = (int)Math.Pow(2, int.Parse(new string(binReader.ReadChars(2))));
            // 开始时间
            string str = Helper.GetStrFromVariableCharArray(binReader);
            string[] subStr = str.Split(new char[] { ',',':','.'});
            if (subStr.Length == 7) {
                header.BeginTime = new DateTime(int.Parse(subStr[0]),
                                                int.Parse(subStr[1]),
                                                int.Parse(subStr[2]),
                                                int.Parse(subStr[3]),
                                                int.Parse(subStr[4]),
                                                int.Parse(subStr[5]),
                                                int.Parse(subStr[6]));
            }
            // 结束时间
            str = Helper.GetStrFromVariableCharArray(binReader);
            subStr = str.Split(',');
            if (subStr.Length == 7) {
                header.EndTime = new DateTime(int.Parse(subStr[0]),
                                              int.Parse(subStr[1]),
                                              int.Parse(subStr[2]),
                                              int.Parse(subStr[3]),
                                              int.Parse(subStr[4]),
                                              int.Parse(subStr[5]),
                                              int.Parse(subStr[6]));
            }
            // 写卷时间
            str = Helper.GetStrFromVariableCharArray(binReader);
            subStr = str.Split(',');
            if (subStr.Length == 7) {
                header.VolumeTime = new DateTime(int.Parse(subStr[0]),
                                                 int.Parse(subStr[1]),
                                                 int.Parse(subStr[2]),
                                                 int.Parse(subStr[3]),
                                                 int.Parse(subStr[4]),
                                                 int.Parse(subStr[5]),
                                                 int.Parse(subStr[6]));
            }

            header.Organization = Helper.GetStrFromVariableCharArray(binReader);
            header.Label = Helper.GetStrFromVariableCharArray(binReader);
        }
        private void ReadBlock011(BinaryReader binReader, ControlHeader header) {
            // 先求出本逻辑记录的剩余空间
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                // 根据SEED规定,不能把分区块的"块类型"和"块长度"[共7字节]
                // 放到不同的逻辑记录中,所以这种情况应直接跳过这些剩余空间
                binReader.BaseStream.Position += remainSpace;
                // 之后设置新的逻辑记录标识块
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                // 不小于7个字节,那么就可以放心地读取分区块的"块类型"和"块长度"[共7字节]
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > blockLength) {
                    // 若剩余空间完全可以容纳本分区块的内容,则可以放心地读取分区块
                    header.StationNum = int.Parse(new string(binReader.ReadChars(3)));
                    // 读取剩余的未读取的字段
                    B011ForFunction(binReader, header, 0);
                }
                else {
                    remainSpace -= 7; // 剩余空间已经在读取分区块的"块类型"和"块长度"[共7字节]减少了7个字节

                    if (remainSpace < 3) {
                        // 剩下的空间无法容纳本分区块的下一个字段
                        // 则应先把在该剩余空间中的数据先保存到一个变量中
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        // 之后设置新的逻辑记录标识块
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        // 读取本分区块该字段还需要的未读取的数据
                        char[] alseNeededChars = binReader.ReadChars(3 - remainSpace);
                        // 并这两个分散读取的字节数组
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        // 用合并后的数据给本分区块跨越逻辑记录标识块的字段赋值
                        header.StationNum = int.Parse(str);
                        // 读取剩余的未读取的字段
                        B011ForFunction(binReader, header, 0);
                    }
                    else {
                        // 若剩余空间还可以保存本分区块的下一个字段,则先读之
                        remainSpace -= 3;
                        header.StationNum = int.Parse(new string(binReader.ReadChars(3)));
                        for (int i = 0; i < header.StationNum; i++) {
                            StationInfo stationInfo = new StationInfo();
                            if (remainSpace < 5) {
                                char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                Helper.SetLogicalRecordIndentBlock(binReader);
                                char[] alseNeededChars = binReader.ReadChars(5 - remainSpace);
                                string str = new string(charsInRemainSpace);
                                str += new string(alseNeededChars);
                                stationInfo.Name = str;
                                stationInfo.Position = int.Parse(new string(binReader.ReadChars(6)));
                                header.StationsPos.Add(stationInfo);
                                // 为了避免For循环一直执行上面几条语句
                                // 所以应将此for循环剥离，其剥离逻辑在以下函数里面
                                B011ForFunction(binReader, header, i + 1);
                                break;
                            }
                            else {
                                remainSpace -= 5;
                                stationInfo.Name = new string(binReader.ReadChars(5));

                                if (remainSpace < 6) {
                                    char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                    Helper.SetLogicalRecordIndentBlock(binReader);
                                    char[] alseNeededChars = binReader.ReadChars(6 - remainSpace);
                                    string temp = new string(charsInRemainSpace);
                                    temp += new string(alseNeededChars);
                                    stationInfo.Position = int.Parse(temp);
                                    header.StationsPos.Add(stationInfo);
                                    // 为了避免For循环一直执行上面几条语句
                                    // 所以应将此for循环剥离，其剥离逻辑在以下函数里面
                                    B011ForFunction(binReader, header, i + 1);
                                    break;
                                }
                                else {
                                    remainSpace -= 6;
                                    stationInfo.Position = int.Parse(new string(binReader.ReadChars(6)));
                                    header.StationsPos.Add(stationInfo);
                                }
                            }
                        }
                    }
                }
            }
        }
        private static void B011ForFunction(BinaryReader binReader, ControlHeader header,int startIndex) {
            for (; startIndex < header.StationNum; startIndex++) {
                StationInfo stationPos = new StationInfo();
                stationPos.Name     = new string(binReader.ReadChars(5));
                stationPos.Position = int.Parse(new string(binReader.ReadChars(6)));
                header.StationsPos.Add(stationPos);
            }
        }
        private void ReadBlock012(BinaryReader binReader, ControlHeader header) {

            // 先求出本逻辑记录的剩余空间
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                // 根据SEED规定,不能把分区块的"块类型"和"块长度"[共7字节]
                // 放到不同的逻辑记录中,所以这种情况应直接跳过这些剩余空间
                binReader.BaseStream.Position += remainSpace;
                // 之后设置新的逻辑记录标识块
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > blockLength) {
                    header.TimeSpanNum = int.Parse(new string(binReader.ReadChars(4)));
                    B012ForFunction(binReader, header, 0);
                }
                else {
                    remainSpace -= 7;

                    if (remainSpace < 4) {
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        char[] alseNeededChars = binReader.ReadChars(4 - remainSpace);
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        header.TimeSpanNum = int.Parse(str);
                        B012ForFunction(binReader, header, 0);
                    }
                    else {
                        remainSpace -= 4;
                        header.TimeSpanNum = int.Parse(new string(binReader.ReadChars(4)));
                        // 申明一个时间信息类实例
                        TimeSpanInfo timeSpan = new TimeSpanInfo();
                        for (int i = 0; i < header.TimeSpanNum; i++) {
                            int lenght = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                            if (remainSpace < lenght) {
                                string str = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                string[] subStr = str.Split(',');
                                
                                // 设置时间片开始时间
                                if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                                    timeSpan.BeginOfSpan = new DateTime(int.Parse(subStr[0]),
                                                                        int.Parse(subStr[1]),
                                                                        int.Parse(subStr[2]),
                                                                        int.Parse(subStr[3]),
                                                                        int.Parse(subStr[4]),
                                                                        int.Parse(subStr[5]),
                                                                        int.Parse(subStr[6]));
                                }
                                // 设置时间片结束时间
                                str = Helper.GetStrFromVariableCharArray(binReader);
                                subStr = str.Split(',');
                                if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                                    timeSpan.EndOfSpan = new DateTime(int.Parse(subStr[0]),
                                                                      int.Parse(subStr[1]),
                                                                      int.Parse(subStr[2]),
                                                                      int.Parse(subStr[3]),
                                                                      int.Parse(subStr[4]),
                                                                      int.Parse(subStr[5]),
                                                                      int.Parse(subStr[6]));
                                }

                                // 获取该时间片所在的逻辑记录的逻辑记录号
                                timeSpan.Position = int.Parse(new string(binReader.ReadChars(6)));
                                header.TimeSpansPos.Add(timeSpan);
                                B012ForFunction(binReader, header, i + 1);
                                break;
                            }
                            else {
                                remainSpace -= lenght;
                                string str = Helper.GetStrFromVariableCharArray(binReader);
                                string[] subStr = str.Split(',');
                                // 设置时间片开始时间
                                if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                                    timeSpan.BeginOfSpan = new DateTime(int.Parse(subStr[0]),
                                                                        int.Parse(subStr[1]),
                                                                        int.Parse(subStr[2]),
                                                                        int.Parse(subStr[3]),
                                                                        int.Parse(subStr[4]),
                                                                        int.Parse(subStr[5]),
                                                                        int.Parse(subStr[6]));
                                }

                                int len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                if (remainSpace < len) {
                                    str = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                    subStr = str.Split(',');
                                    if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                                        timeSpan.EndOfSpan = new DateTime(int.Parse(subStr[0]),
                                                                          int.Parse(subStr[1]),
                                                                          int.Parse(subStr[2]),
                                                                          int.Parse(subStr[3]),
                                                                          int.Parse(subStr[4]),
                                                                          int.Parse(subStr[5]),
                                                                          int.Parse(subStr[6]));
                                    }
                                    // 获取该时间片所在的逻辑记录的逻辑记录号
                                    timeSpan.Position = int.Parse(new string(binReader.ReadChars(6)));
                                    header.TimeSpansPos.Add(timeSpan);
                                    B012ForFunction(binReader, header, i + 1);
                                    break;
                                }
                                else {
                                    remainSpace -= len;
                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                    subStr = str.Split(new char[] { ',', ':', '.' });
                                    if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                                        timeSpan.EndOfSpan = new DateTime(int.Parse(subStr[0]),
                                                                          int.Parse(subStr[1]),
                                                                          int.Parse(subStr[2]),
                                                                          int.Parse(subStr[3]),
                                                                          int.Parse(subStr[4]),
                                                                          int.Parse(subStr[5]),
                                                                          int.Parse(subStr[6]));
                                    }
                                    if (remainSpace < 6) {
                                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                        Helper.SetLogicalRecordIndentBlock(binReader);
                                        char[] alseNeededChars = binReader.ReadChars(6 - remainSpace);
                                        string temp = new string(charsInRemainSpace);
                                        temp += new string(alseNeededChars);
                                        timeSpan.Position = int.Parse(temp);
                                        header.TimeSpansPos.Add(timeSpan);
                                        B012ForFunction(binReader, header, i + 1);
                                        break;
                                    }
                                    else {
                                        remainSpace -= 6;
                                        timeSpan.Position = int.Parse(new string(binReader.ReadChars(6)));
                                        header.TimeSpansPos.Add(timeSpan);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        private void B012ForFunction(BinaryReader binReader, ControlHeader header, int startIndex) {
            for (; startIndex < header.TimeSpanNum; startIndex++) {
                // 申明一个时间信息类实例
                TimeSpanInfo timeSpan = new TimeSpanInfo();
                // 用前面申明的变量保存
                string str = Helper.GetStrFromVariableCharArray(binReader);
                string[] subStr = str.Split(',', ':', '.');
                // 设置时间片开始时间
                if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                    timeSpan.BeginOfSpan = new DateTime(int.Parse(subStr[0]),
                                                        int.Parse(subStr[1]),
                                                        int.Parse(subStr[2]),
                                                        int.Parse(subStr[3]),
                                                        int.Parse(subStr[4]),
                                                        int.Parse(subStr[5]),
                                                        int.Parse(subStr[6]));
                }
                // 设置时间片结束时间
                str = Helper.GetStrFromVariableCharArray(binReader);
                subStr = str.Split(',', ':', '.');
                if (subStr.Length == 7) { // 一般情况下不会小于6，所以不写else
                    timeSpan.EndOfSpan = new DateTime(int.Parse(subStr[0]),
                                                      int.Parse(subStr[1]),
                                                      int.Parse(subStr[2]),
                                                      int.Parse(subStr[3]),
                                                      int.Parse(subStr[4]),
                                                      int.Parse(subStr[5]),
                                                      int.Parse(subStr[6]));
                }

                // 获取该时间片所在的逻辑记录的逻辑记录号
                timeSpan.Position = int.Parse(new string(binReader.ReadChars(6)));
                header.TimeSpansPos.Add(timeSpan);
            }
        }
        private void ReadAbbDict(BinaryReader binReader, ControlHeader header) {
            // 由于是新的一种控制头段开始
            // 根据SEED规定，不同的控制头段不能放在不同的逻辑记录中，
            // 所以无论上一逻辑记录剩余空间有多大，都应跳过
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * header.LogicalRecordLength - binReader.BaseStream.Position);
            binReader.BaseStream.Position += remainSpace;
            // 设置新的逻辑记录标识块
            Helper.SetLogicalRecordIndentBlock(binReader);
            // 读取数据格式分区块[030]
            ReadBlock030(binReader, header.DataFormats);
            // 读取注释描述分区块[031]
            ReadBlock031(binReader, header.Comments);
            // 读取一般简写分区块[033]
            ReadBlock033(binReader, header.GenericDicts);
            // 读取单位分区块[034]
            ReadBlock034(binReader,header.Units);
            // 读取引用源字典分区块[032]
            ReadBlock032(binReader,header.CitedSources);
        }
        private void ReadBlock030(BinaryReader binReader, List<DataFormat> list) {
            // 先读取单个DataFormat,之后再添加到List<DataFormat>中
            DataFormat format = new DataFormat();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                // 跳过块类型
                binReader.BaseStream.Position += 3;
                // 获得本块的长度
                int length = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > length) {
                    format.Name = Helper.GetStrFromVariableCharArray(binReader);
                    format.ID   = int.Parse(new string(binReader.ReadChars(4)));
                    format.Type = int.Parse(new string(binReader.ReadChars(3)));
                    int keysNum = int.Parse(new string(binReader.ReadChars(2)));
                    B030ForFunction(binReader, format, keysNum, 0);
                }
                else {
                    remainSpace -= 7;

                    int len = Helper.GetVariavleCharArrayLength(binReader, (int)remainSpace);
                    if (remainSpace < length) {
                        format.Name = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                        format.ID   = int.Parse(new string(binReader.ReadChars(4)));
                        format.Type = int.Parse(new string(binReader.ReadChars(3)));
                        int keysNum = int.Parse(new string(binReader.ReadChars(2)));
                        B030ForFunction(binReader, format, keysNum, 0);
                    }
                    else {
                        remainSpace -= len;
                        format.Name = Helper.GetStrFromVariableCharArray(binReader);

                        if (remainSpace < 4) {
                            char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                            Helper.SetLogicalRecordIndentBlock(binReader);
                            char[] alseNeededChars = binReader.ReadChars(4 - remainSpace);
                            string str  = new string(charsInRemainSpace);
                            str += new string(alseNeededChars);
                            format.ID   = int.Parse(str);
                            format.Type = int.Parse(new string(binReader.ReadChars(3)));
                            int keysNum = int.Parse(new string(binReader.ReadChars(2)));
                            B030ForFunction(binReader, format, keysNum, 0);
                        }
                        else {
                            remainSpace -= 4;
                            format.ID = int.Parse(new string(binReader.ReadChars(4)));

                            if (remainSpace < 3) {
                                char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                Helper.SetLogicalRecordIndentBlock(binReader);
                                char[] alseNeededChars = binReader.ReadChars(3 - remainSpace);
                                string str = new string(charsInRemainSpace);
                                str += new string(alseNeededChars);
                                format.Type = int.Parse(str);
                                int keysNum = int.Parse(new string(binReader.ReadChars(2)));
                                B030ForFunction(binReader, format, keysNum, 0);
                            }
                            else {
                                remainSpace -= 3;
                                format.Type = int.Parse(new string(binReader.ReadChars(3)));

                                if (remainSpace < 2) {
                                    char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                    Helper.SetLogicalRecordIndentBlock(binReader);
                                    char[] alseNeededChars = binReader.ReadChars(2 - remainSpace);
                                    string str = new string(charsInRemainSpace);
                                    str += new string(alseNeededChars);
                                    int keysNum = int.Parse(str);
                                    B030ForFunction(binReader, format, keysNum, 0);
                                }
                                else {
                                    remainSpace -= 2;
                                    int keysNum = int.Parse(new string(binReader.ReadChars(2)));

                                    int keylen = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                    for (short i = 0; i < keysNum; i++) {
                                        if (remainSpace < len) {
                                            format.Keys.Add(Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace));
                                            B030ForFunction(binReader, format, keysNum, i + 1);
                                            break;
                                        }
                                        else {
                                            remainSpace -= keylen;

                                            format.Keys.Add(Helper.GetStrFromVariableCharArray(binReader));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            list.Add(format);
            //
            // 以下对循环此函数进行逻辑控制
            //
            // 再循环之前对剩余空间重新进行计算是必要的,因为在读取本分区块的过程中有可能动态生成了新的逻辑记录标识块
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
                int blockType = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockType == 30) {
                    ReadBlock030(binReader, list);
                }
            }
            else {
                int blockType = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockType == 30) {
                    ReadBlock030(binReader, list);
                }
            }
        }
        private void B030ForFunction(BinaryReader binReader, DataFormat format, int keysNum, int startIndex) {
            for (; startIndex < keysNum; startIndex++) {
                format.Keys.Add(Helper.GetStrFromVariableCharArray(binReader));
            }
        }
        private void ReadBlock031(BinaryReader binReader, List<Comment> list) {
            Comment comment = new Comment();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > blockLength) {
                    comment.ID = int.Parse(new string(binReader.ReadChars(4)));
                    comment.ClassCode = binReader.ReadChar();
                    comment.Comments = Helper.GetStrFromVariableCharArray(binReader);
                    comment.UnitsLevel = int.Parse(new string(binReader.ReadChars(3)));
                }
                else {
                    remainSpace -= 7;

                    if (remainSpace < 4) {
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        char[] alseNeededChars = binReader.ReadChars(4 - remainSpace);
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        comment.ID = int.Parse(str);
                        // 由于刚开始一个新的逻辑记录，而本分区块长度最大只有85字节，所以
                        // 不用担心还会大于一个逻辑记录的情况，也即可以放心读取完本分区块内容
                        comment.ClassCode = binReader.ReadChar();
                        comment.Comments = Helper.GetStrFromVariableCharArray(binReader);
                        comment.UnitsLevel = int.Parse(new string(binReader.ReadChars(3)));
                    }
                    else {
                        remainSpace -= 4;
                        comment.ID = int.Parse(new string(binReader.ReadChars(4)));

                        if (remainSpace < 1) { // 因不可能为负值,所以也就是0
                            Helper.SetLogicalRecordIndentBlock(binReader);
                            comment.ClassCode = binReader.ReadChar();
                            comment.Comments = Helper.GetStrFromVariableCharArray(binReader);
                            comment.UnitsLevel = int.Parse(new string(binReader.ReadChars(3)));
                        }
                        else {
                            remainSpace -= 1;
                            comment.ClassCode = binReader.ReadChar();

                            int length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                            if (remainSpace < length) {
                                comment.Comments = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                comment.UnitsLevel = int.Parse(new string(binReader.ReadChars(3)));
                            }
                            else {
                                remainSpace -= length;
                                comment.Comments = Helper.GetStrFromVariableCharArray(binReader);

                                if (remainSpace < 3) {
                                    char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                                    Helper.SetLogicalRecordIndentBlock(binReader);
                                    char[] alseNeededChars = binReader.ReadChars(3 - remainSpace);
                                    string str = new string(charsInRemainSpace);
                                    str += new string(alseNeededChars);
                                    comment.UnitsLevel = int.Parse(str);
                                }
                                else {
                                    remainSpace -= 3;
                                    comment.UnitsLevel = int.Parse(new string(binReader.ReadChars(3)));
                                }
                            }
                        }
                    }
                }
            }
            list.Add(comment);
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 31) {
                    ReadBlock031(binReader, list);
                }
            }
            else {
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 31) {
                    ReadBlock031(binReader, list);
                }
            }
        }
        private void ReadBlock033(BinaryReader binReader, List<GenericDict> list) {
            GenericDict genericDict = new GenericDict();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                binReader.BaseStream.Position += 3;
                string test = new string(binReader.ReadChars(4));
                int blockLength = int.Parse(test);

                if (remainSpace > blockLength) {
                    genericDict.ID = int.Parse(new string(binReader.ReadChars(3)));
                    genericDict.Description = Helper.GetStrFromVariableCharArray(binReader);
                }
                else {
                    remainSpace -= 7;

                    if (remainSpace < 3) {
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        char[] alseNeededChars = binReader.ReadChars(3 - remainSpace);
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        genericDict.ID = int.Parse(str);
                        genericDict.Description = Helper.GetStrFromVariableCharArray(binReader);
                    }
                    else {
                        remainSpace -= 3;
                        genericDict.ID = int.Parse(new string(binReader.ReadChars(3)));

                        int length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                        if (remainSpace < length) {
                            genericDict.Description = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                        }
                        else {
                            remainSpace -= length;
                            genericDict.Description = Helper.GetStrFromVariableCharArray(binReader);
                        }
                    }
                }
            }
            list.Add(genericDict);
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 33) {
                    ReadBlock033(binReader, list);
                }
            }
            else {
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 33) {
                    ReadBlock033(binReader, list);
                }
            }

        }
        private void ReadBlock034(BinaryReader binReader, List<Unit> list) {
            Unit unit = new Unit();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > blockLength) {
                    unit.ID = int.Parse(new string(binReader.ReadChars(3)));
                    unit.UnitName = Helper.GetStrFromVariableCharArray(binReader);
                    unit.UnitDescription = Helper.GetStrFromVariableCharArray(binReader);
                }
                else {
                    remainSpace -= 7;

                    if (remainSpace < 3) {
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        char[] alseNeededChars = binReader.ReadChars(3 - remainSpace);
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        unit.ID = int.Parse(str);
                        unit.UnitName = Helper.GetStrFromVariableCharArray(binReader);
                        unit.UnitDescription = Helper.GetStrFromVariableCharArray(binReader);
                    }
                    else {
                        remainSpace -= 3;
                        unit.ID = int.Parse(new string(binReader.ReadChars(3)));

                        int length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                        if (remainSpace < length) {
                            unit.UnitName = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                            unit.UnitDescription = Helper.GetStrFromVariableCharArray(binReader);
                        }
                        else {
                            remainSpace -= length;
                            unit.UnitName = Helper.GetStrFromVariableCharArray(binReader);

                            int len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                            if (remainSpace < len) {
                                unit.UnitDescription = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                            }
                            else {
                                remainSpace -= len;
                                unit.UnitDescription = Helper.GetStrFromVariableCharArray(binReader);
                            }
                        }
                    }
                }
            }
            list.Add(unit);
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 34) {
                    ReadBlock034(binReader, list);
                }
            }
            else {
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 34) {
                    ReadBlock034(binReader, list);
                }
            }
        }
        private void ReadBlock032(BinaryReader binReader, List<CitedSource> list) {
            CitedSource citedSource = new CitedSource();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));

                if (remainSpace > blockLength) {
                    citedSource.ID = int.Parse(new string(binReader.ReadChars(2)));
                    citedSource.AuthorName = Helper.GetStrFromVariableCharArray(binReader);
                    citedSource.Catalog = Helper.GetStrFromVariableCharArray(binReader);
                    citedSource.Publisher = Helper.GetStrFromVariableCharArray(binReader);
                }
                else {
                    remainSpace -= 7;

                    if (remainSpace < 2) {
                        char[] charsInRemainSpace = binReader.ReadChars(remainSpace);
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        char[] alseNeededChars = binReader.ReadChars(2 - remainSpace);
                        string str = new string(charsInRemainSpace);
                        str += new string(alseNeededChars);
                        citedSource.ID = int.Parse(str);
                        citedSource.AuthorName = Helper.GetStrFromVariableCharArray(binReader);
                        binReader.BaseStream.Position += Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                        citedSource.Publisher = Helper.GetStrFromVariableCharArray(binReader);
                    }
                    else {
                        remainSpace -= 2;

                        int length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                        if (remainSpace < length) {
                            citedSource.AuthorName = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace); ;
                            binReader.BaseStream.Position += Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                            citedSource.Publisher = Helper.GetStrFromVariableCharArray(binReader);
                        }
                        else {
                            remainSpace -= length;

                            int len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                            if (remainSpace < len) {
                                binReader.BaseStream.Position += len;
                                citedSource.Publisher = Helper.GetStrFromVariableCharArray(binReader);
                            }
                            else {
                                remainSpace -= len;
                                binReader.BaseStream.Position += len;

                                len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                if (remainSpace < len) {
                                    citedSource.Publisher = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                }
                            }
                        }
                    }
                }
            }
            list.Add(citedSource);
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * LogicalRecordLenght - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
                int blockID = int.Parse(new string(binReader.ReadChars(3)));
                binReader.BaseStream.Position -= 3;
                if (blockID == 32) {
                    ReadBlock032(binReader, list);
                }
            }
            else {
                int blockID = int.Parse(new string(binReader.ReadChars(3)).Replace(" ", "0"));
                binReader.BaseStream.Position -= 3;
                if (blockID == 32) {
                    ReadBlock032(binReader, list);
                }
            }
        }
        #endregion

        #region 读取站点控制头段[只读取本项目认为重要的部分有用信息]
        /* 备注0：关于该读取该控制头段的说明
         * 在读取台站控制头段信息时，由于信息量非常大
         * 而本人在做该项目时时间又非常紧迫，所以没有将信息
         * 全部读出，而是将该台站控制头段设置成了一个台站列表
         * 该列表中的各台站又包含一个该台站的通道列表。也就是说
         * 该控制头段被设置成了台网信息类
         */
        
        private void ReadStations(BinaryReader binReader, List<Station> list) {
            #region 进度条
            // 由于以下代码需要很长时间，所以显示进度条以混淆交互特性
            DataFileReading dataFileReadingProcess = new DataFileReading();
            dataFileReadingProcess.StartPosition = FormStartPosition.CenterScreen;
            dataFileReadingProcess.Show();
            dataFileReadingProcess.progressBar.Maximum = Header.StationNum;
            dataFileReadingProcess.progressBar.Minimum = 0;
            dataFileReadingProcess.progressBar.Step = 1;
            string Percent = "0.00%";
            #endregion
            // 由于台站数目一步不止一个，所以这里我们使用循环来控制读取所有台站
            for (int i = 0; i < Header.StationNum; i++) {
                #region 进度条的内容
                dataFileReadingProcess.progressBar.Value = i;
                dataFileReadingProcess.progressBar.Update();
                Percent = string.Format("{0}%", (100.0 * (double)i / Header.StationNum));
                dataFileReadingProcess.Text = Percent;
                #endregion
                // 建立一个台站信息类实例
                Station station = new Station();
                // 通过卷台站索引分区块[011]的内容得到当前台站的所在逻辑记录起始位置
                // [当然如果是第一个站台也可以通过跳过简写字典控制头的剩余的空间得到同样的信息]
                binReader.BaseStream.Position = (Header.StationsPos[i].Position - 1) * Header.LogicalRecordLength;
                // 调用实例函数获得相关信息
                station.ReadStaion(binReader, Header);
                list.Add(station);
            }
            // 关闭进度条
            dataFileReadingProcess.Dispose();
        }
        #endregion

        #region 读取时间控制头段[简化]
        private void ReadTimeSpanConHeader(BinaryReader binReader, TimeSpanConH tsch) {
            // 定位基础流位置
            //注：这里简化[已经知道了只有一个]。
            binReader.BaseStream.Position = (Header.TimeSpansPos[0].Position - 1) * Header.LogicalRecordLength;
            Helper.SetLogicalRecordIndentBlock(binReader);
            //
            // 读取块[070]
            //
            // 跳过块类型和长度
            binReader.BaseStream.Position += 7;
            tsch.TimeSpanFlag = binReader.ReadChar();
            tsch.BeginTime    = Helper.GetStrFromVariableCharArray(binReader);
            tsch.EndTime      = Helper.GetStrFromVariableCharArray(binReader);
            //
            // 读取块[071]---简化
            //
            binReader.BaseStream.Position += 7;
            tsch.OriginTimeOfEvent = Helper.GetStrFromVariableCharArray(binReader);
            binReader.BaseStream.Position += 2;
            tsch.Latitude  = float.Parse(new string(binReader.ReadChars(10)));
            tsch.Longitude = float.Parse(new string(binReader.ReadChars(11)));
            tsch.Depth     = float.Parse(new string(binReader.ReadChars(7)));
            binReader.BaseStream.Position += 2;
            tsch.Magnitude = float.Parse(new string(binReader.ReadChars(5)));
            // 不接收数据达到跳过的目的
            Helper.GetStrFromVariableCharArray(binReader);
            //
            binReader.BaseStream.Position += 9;
            tsch.RegionName = Helper.GetStrFromVariableCharArray(binReader);
            //
            // 度时间序列
            //
            ReadTimeSeries(binReader, tsch.TimeSeries);

        }

        //private void ReadTimeSeries(BinaryReader binReader, List<TimeSeriesInfo> list) {
        //    // 先读取一个，然后再添加进入列表
        //}   TimeSeriesInfo timeSeries = new TimeSeriesInfo();

        private void ReadTimeSeries(BinaryReader binReader, List<TimeSeriesInfo> list) {
            // 先读取一个，然后再添加进入列表
            TimeSeriesInfo timeSeries = new TimeSeriesInfo();
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * Header.LogicalRecordLength - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                //跳过块类型和长度
                binReader.BaseStream.Position += 3;
                int blockLen = int.Parse(new string(binReader.ReadChars(4)));
                if (remainSpace > blockLen) {
                    timeSeries.StationName = new string(binReader.ReadChars(5));
                    binReader.BaseStream.Position += 2;
                    timeSeries.ChannelName = new string(binReader.ReadChars(3));
                    timeSeries.SeriesStartTime = Helper.GetStrFromVariableCharArray(binReader);
                    timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                    binReader.BaseStream.Position += 2;
                    timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                    timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                    binReader.BaseStream.Position += 2;
                    // 以下循环跳过暂时认为不需要的内容
                    int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                    for (int i = 0; i < acceleratorNum; i++) {
                        Helper.GetStrFromVariableCharArray(binReader);
                        binReader.BaseStream.Position += 8;
                    }
                    timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                }
                #region 空间不足的情况
                else {
                    remainSpace -= 7;
                    if (remainSpace < 5) {
                        timeSeries.StationName = Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 5);
                        // 因为刚开始一个逻辑记录且本分区块的长度不可能大于一个逻辑记录的长度，
                        //所以本分区块的余下内容可以放心读取
                        binReader.BaseStream.Position += 2;
                        timeSeries.ChannelName = new string(binReader.ReadChars(3));
                        timeSeries.SeriesStartTime = Helper.GetStrFromVariableCharArray(binReader);
                        timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                        binReader.BaseStream.Position += 2;
                        timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                        timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                        binReader.BaseStream.Position += 2;
                        // 以下循环跳过暂时认为不需要的内容
                        int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                        for (int i = 0; i < acceleratorNum; i++) {
                            Helper.GetStrFromVariableCharArray(binReader);
                            binReader.BaseStream.Position += 8;
                        }
                        timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                    }
                    else {
                        remainSpace -= 5;
                        timeSeries.StationName = new string(binReader.ReadChars(5));
                        if (remainSpace < 2) {
                            Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                            // 因为刚开始一个逻辑记录且本分区块的长度不可能大于一个逻辑记录的长度，
                            //所以本分区块的余下内容可以放心读取
                            timeSeries.ChannelName = new string(binReader.ReadChars(3));
                            timeSeries.SeriesStartTime = Helper.GetStrFromVariableCharArray(binReader);
                            timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                            binReader.BaseStream.Position += 2;
                            timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                            timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                            binReader.BaseStream.Position += 2;
                            // 以下循环跳过暂时认为不需要的内容
                            int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                            for (int i = 0; i < acceleratorNum; i++) {
                                Helper.GetStrFromVariableCharArray(binReader);
                                binReader.BaseStream.Position += 8;
                            }
                            timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                        }
                        else {
                            remainSpace -= 2;
                            binReader.BaseStream.Position += 2;
                            if (remainSpace < 3) {
                                timeSeries.ChannelName = Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 5);
                                timeSeries.SeriesStartTime = Helper.GetStrFromVariableCharArray(binReader);
                                timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                binReader.BaseStream.Position += 2;
                                timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                                timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                binReader.BaseStream.Position += 2;
                                // 以下循环跳过暂时认为不需要的内容
                                int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                for (int i = 0; i < acceleratorNum; i++) {
                                    Helper.GetStrFromVariableCharArray(binReader);
                                    binReader.BaseStream.Position += 8;
                                }
                                timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                            }
                            else {
                                remainSpace -= 3;
                                timeSeries.ChannelName = new string(binReader.ReadChars(3));
                                int length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                if (remainSpace < length) {
                                    timeSeries.SeriesStartTime = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                    timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                    binReader.BaseStream.Position += 2;
                                    timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                                    timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                    binReader.BaseStream.Position += 2;
                                    // 以下循环跳过暂时认为不需要的内容
                                    int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                    for (int i = 0; i < acceleratorNum; i++) {
                                        Helper.GetStrFromVariableCharArray(binReader);
                                        binReader.BaseStream.Position += 8;
                                    }
                                    timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                }
                                else {
                                    remainSpace -= length;
                                    timeSeries.SeriesStartTime = Helper.GetStrFromVariableCharArray(binReader);
                                    if (remainSpace < 6) {
                                        timeSeries.FirstDataSeq = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 6);
                                        binReader.BaseStream.Position += 2;
                                        timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                                        timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                        binReader.BaseStream.Position += 2;
                                        // 以下循环跳过暂时认为不需要的内容
                                        int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                        for (int i = 0; i < acceleratorNum; i++) {
                                            Helper.GetStrFromVariableCharArray(binReader);
                                            binReader.BaseStream.Position += 8;
                                        }
                                        timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                    }
                                    else {
                                        remainSpace -= 6;
                                        timeSeries.FirstDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                        if (remainSpace < 2) {
                                            Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                                            timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                                            timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                            binReader.BaseStream.Position += 2;
                                            // 以下循环跳过暂时认为不需要的内容
                                            int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                            for (int i = 0; i < acceleratorNum; i++) {
                                                Helper.GetStrFromVariableCharArray(binReader);
                                                binReader.BaseStream.Position += 8;
                                            }
                                            timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                        }
                                        else {
                                            remainSpace -= 2;
                                            binReader.BaseStream.Position += 2;
                                            length = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                            if (remainSpace < length) {
                                                timeSeries.SeriesEndTime = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                                timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                                binReader.BaseStream.Position += 2;
                                                // 以下循环跳过暂时认为不需要的内容
                                                int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                                for (int i = 0; i < acceleratorNum; i++) {
                                                    Helper.GetStrFromVariableCharArray(binReader);
                                                    binReader.BaseStream.Position += 8;
                                                }
                                                timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                            }
                                            else {
                                                remainSpace -= length;
                                                timeSeries.SeriesEndTime = Helper.GetStrFromVariableCharArray(binReader);
                                                if (remainSpace < 6) {
                                                    timeSeries.LastDataSeq = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 6);
                                                    binReader.BaseStream.Position += 2;
                                                    // 以下循环跳过暂时认为不需要的内容
                                                    int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                                    for (int i = 0; i < acceleratorNum; i++) {
                                                        Helper.GetStrFromVariableCharArray(binReader);
                                                        binReader.BaseStream.Position += 8;
                                                    }
                                                    timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                }
                                                else {
                                                    remainSpace -= 6;
                                                    timeSeries.LastDataSeq = int.Parse(new string(binReader.ReadChars(6)));
                                                    if (remainSpace < 2) {
                                                        Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                                                        // 以下循环跳过暂时认为不需要的内容
                                                        int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                                        for (int i = 0; i < acceleratorNum; i++) {
                                                            Helper.GetStrFromVariableCharArray(binReader);
                                                            binReader.BaseStream.Position += 8;
                                                        }
                                                        timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                    }
                                                    else {
                                                        remainSpace -= 2;
                                                        binReader.BaseStream.Position += 2;
                                                        if (remainSpace < 3) {
                                                            int num = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 3);
                                                            for (int i = 0; i < num; i++) {
                                                                Helper.GetStrFromVariableCharArray(binReader);
                                                                binReader.BaseStream.Position += 8;
                                                            }
                                                            timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                        }
                                                        else { // 从这里，以下逻辑有点悲剧
                                                            remainSpace -= 3;
                                                            int acceleratorNum = int.Parse(new string(binReader.ReadChars(3)));
                                                            int len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                                            if (remainSpace < len) {
                                                                Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                                                binReader.BaseStream.Position += 8;
                                                                if (--acceleratorNum != 0) {
                                                                    for (int i = 0; i < acceleratorNum; i++) {
                                                                        Helper.GetStrFromVariableCharArray(binReader);
                                                                        binReader.BaseStream.Position += 8;
                                                                    }
                                                                }
                                                                timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                            }
                                                            else {
                                                                remainSpace -= len;
                                                                Helper.GetStrFromVariableCharArray(binReader);
                                                                if (remainSpace < 6) {
                                                                    Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 6);
                                                                    binReader.BaseStream.Position += 2;
                                                                    if (--acceleratorNum != 0) {
                                                                        for (int i = 0; i < acceleratorNum; i++) {
                                                                            Helper.GetStrFromVariableCharArray(binReader);
                                                                            binReader.BaseStream.Position += 8;
                                                                        }
                                                                    }
                                                                    timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                                }
                                                                else {
                                                                    remainSpace -= 6;
                                                                    binReader.BaseStream.Position += 6;
                                                                    if (remainSpace < 2) {
                                                                        Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                                                                        if (--acceleratorNum != 0) {
                                                                            for (int i = 0; i < acceleratorNum; i++) {
                                                                                Helper.GetStrFromVariableCharArray(binReader);
                                                                                binReader.BaseStream.Position += 8;
                                                                            }
                                                                        }
                                                                        timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                                    }
                                                                    else {
                                                                        remainSpace -= 2;
                                                                        binReader.BaseStream.Position += 2;
                                                                        if (--acceleratorNum != 0) {
                                                                            for (int i = 0; i < acceleratorNum; i++) {
                                                                                Helper.GetStrFromVariableCharArray(binReader);
                                                                                binReader.BaseStream.Position += 8;
                                                                            }
                                                                        }
                                                                        if (remainSpace < 2) {
                                                                            timeSeries.NetworkCode = Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                                                                        }
                                                                        else {
                                                                            remainSpace -= 2;
                                                                            timeSeries.NetworkCode = new string(binReader.ReadChars(2));
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion

            }
            list.Add(timeSeries);
            // 话说悲剧发生了，这里读取数据会是内存爆满，嘟~
            // 所以两百个就退出了，不读了，以后吧可以设置参数来控制
            if (list.Count == 200) {
                return;
            }
            //循环调用此函数
            remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * Header.LogicalRecordLength - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += 7;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {//大于7字节，但是仍然可能是当前控制头段读取完毕，即也是用空格填满，这情况应该退出
                string str = new string(binReader.ReadChars(3));
                // 把基础流的位置还原为原来的位置
                binReader.BaseStream.Position -= 3;
                if (str == "   ") {
                    return;
                }
                else {
                    if (int.Parse(str) == 74) {
                        ReadTimeSeries(binReader, list);
                    }
                    else { // 是一个新的块，但是不是块[074]也退出。
                        return;
                    }
                }
            }
        }
        #endregion

        private void ReadWaveForm(BinaryReader binReader, List<SEEDModels.Waveform> list) {
            //把基础流的位置定位到数据记录开始处
            return;
        }
    }

    public class ControlHeader {
        public float    Version             { get; set; }
        public int      LogicalRecordLength { get; set; }
        public DateTime BeginTime           { get; set; }
        public DateTime EndTime             { get; set; }
        public DateTime VolumeTime          { get; set; }
        public string   Organization        { get; set; }
        public string   Label               { get; set; }
        public int StationNum  { get; set; }
        public int TimeSpanNum { get; set; }

        public List<StationInfo>  StationsPos  { get; set; }
        public List<TimeSpanInfo> TimeSpansPos { get; set; }
        public List<DataFormat>   DataFormats  { get; set; }
        public List<Comment>      Comments     { get; set; }
        public List<CitedSource>  CitedSources { get; set; }
        public List<GenericDict>  GenericDicts { get; set; }
        public List<Unit>         Units        { get; set; }

        public ControlHeader() {
            StationsPos  = new List<StationInfo>();
            TimeSpansPos = new List<TimeSpanInfo>();
            DataFormats  = new List<DataFormat>();
            Comments     = new List<Comment>();
            CitedSources = new List<CitedSource>();
            GenericDicts = new List<GenericDict>();
            Units        = new List<Unit>();
        }
    }

    public class Station {
        public string   Name        { get; set; }
        public float    Latitude    { get; set; }
        public float    Longitude   { get; set; }
        public float    Elevation   { get; set; }
        public int      NumChannel  { get; set; }
        public string   SiteName    { get; set; }
        public int      NetworkID   { get; set; }
        public int      B32WordOrder{ get; set; }
        public short    B16WordOrder{ get; set; }
        public DateTime StartDate   { get; set; }
        public DateTime EndDate     { get; set; }
        public char     UpdateFlag  { get; set; }
        public string   NetworkCode { get; set; }

        public List<Channel> Channels { get; set; }

        public Station() {
            Channels = new List<Channel>();
            if (Channels.Count != 0) {
                Channels.Clear();
            }
        }

        public void ReadStaion(BinaryReader binReader, ControlHeader Header) {
            
            // 设置逻辑记录标识块
            Helper.SetLogicalRecordIndentBlock(binReader);
            // 由于此时刚开始一个新的逻辑记录，而台站标识块[050]最大长度只有163个字节，根据SEED规定：
            // 一个逻辑记录的最小长度不得小于256个字节
            // 所以可以放心地读取本分区块的内容而不用担心当前基础流的位置超出本逻辑记录的空间
            // 
            // 先跳过台站标识块[050]的块类型和块长度字段[共7个字节]
            binReader.BaseStream.Position += 7;
            Name = new string(binReader.ReadChars(5));// 台站名称
            // 如果需要检查文件是否是有效文件，可以通过
            // if(station.Name != Header.StationsPos[i].Name)来判断
            // 本人在此暂时省去此逻辑，待后续完善
            Latitude   = float.Parse(new string(binReader.ReadChars(10))); // 台站纬度
            Longitude  = float.Parse(new string(binReader.ReadChars(11))); // 台站经度
            Elevation  = float.Parse(new string(binReader.ReadChars(7)));  // 台站海拔
            NumChannel = int.Parse(new string(binReader.ReadChars(4)));    // 台站通道数
            // 暂存[主要用于后面逻辑控制]表示台站有多少注释分区块数的字段
            int numOfCommt = int.Parse(new string(binReader.ReadChars(3)));
            // 或者台站的台站行政名称[注明台站地址、市、省、国]
            SiteName = Helper.GetStrFromVariableCharArray(binReader);
            // 获取台站的台网标识码[引自[033]的字段3]
            NetworkID = int.Parse(new string(binReader.ReadChars(3)));
            // 以下两个字段数据记录的固定头段和分区块需要使用
            // 其值因机器类型的不同而有特定的值
            B32WordOrder = int.Parse(new string(binReader.ReadChars(4)));
            B16WordOrder = short.Parse(new string(binReader.ReadChars(2)));
            string str   = Helper.GetStrFromVariableCharArray(binReader);
            string[] subStr = str.Split(',', ':','.');
            if (subStr.Length == 7) {
                StartDate = new DateTime(int.Parse(subStr[0]),
                                         int.Parse(subStr[1]),
                                         int.Parse(subStr[2]),
                                         int.Parse(subStr[3]),
                                         int.Parse(subStr[4]),
                                         int.Parse(subStr[5]),
                                         int.Parse(subStr[6]));
            }
            str = Helper.GetStrFromVariableCharArray(binReader);
            subStr = str.Split(',', ':','.');
            if (subStr.Length == 7) {
                EndDate = new DateTime(int.Parse(subStr[0]),
                                       int.Parse(subStr[1]),
                                       int.Parse(subStr[2]),
                                       int.Parse(subStr[3]),
                                       int.Parse(subStr[4]),
                                       int.Parse(subStr[5]),
                                       int.Parse(subStr[6]));
            }
            UpdateFlag  = binReader.ReadChar();
            NetworkCode = new string(binReader.ReadChars(2));
            //
            // 如果有台站注释分区块，则跳过
            if (numOfCommt > 0) { // 此值可能为0或者某个正数
                for (int i = 0; i < numOfCommt; i++) {
                    // 跳过块类型字段
                    binReader.BaseStream.Position += 3;
                    // 获取该分区块的长度
                    int length = int.Parse(new string(binReader.ReadChars(4)));
                    // 实现跳过注释分区块内容
                    binReader.BaseStream.Position += (length - 7);
                }
            }
            
            // 循环获取该台站所包含的通道信息。注意此过程非常复杂，会跳过很多此项目认为不重要的信息，在跳过这些
            // 本项目不需要的信息时可能会跨越几个逻辑记录，所以必须对的每一逻辑记录的剩余空间进行合理判断和处理
            // 这也是完善本项目的难点所在。建议在完善此项目时，把这些跳过的信息全部读出，因为这些信息本身是描述该台站各通道特征的。
            for (int i = 0; i < NumChannel; i++) {
               
                Channel channel = new Channel();
                channel.ReadChannel(binReader,Header);
                Channels.Add(channel);
                while (true) {
                    // 为了跳过顺利跳过不需要的分区块，应该先计算当前逻辑记录的剩余空间
                    
                    int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * Header.LogicalRecordLength - binReader.BaseStream.Position);
                    // 然后判断该剩余空间是不小于7，若是，则本身应该逃过该改空间
                    if (remainSpace < 7) {
                        binReader.BaseStream.Position += remainSpace;
                        Helper.SetLogicalRecordIndentBlock(binReader);
                    }
                    else {
                        // 不小于7也有可能需要跳过，该情况是在下一逻辑记录跟当前逻辑记录
                        // 不具有连续性的情况下也应该跳过此剩余空间。
                        // 至于连续与否，可以通过获取三字节的内容进行判断，如果
                        // 三字节的内容都是空格，则说明应该跳过此剩余空间。反之，则应该进行块类型判断
                        // 如果是如果是通道分区块，则应跳出该处理过程而进入下一循环
                        string typeStr = new string(binReader.ReadChars(3)).Replace(" ","0");
                        int blockType = int.Parse(typeStr);
                        if (blockType == 0) {
                            // 不能忘记减去3
                            binReader.BaseStream.Position += remainSpace - 3;
                            Helper.SetLogicalRecordIndentBlock(binReader);
                        }
                        else if ((blockType == 52)||(blockType == 50) || (blockType == 70)) { //等于70说明已经到达时间片了
                            binReader.BaseStream.Position -= 3;
                            break;
                        }
                        else {
                            // 若以上两者都不是，则获取该分区块的块长度[该长度包括块本身的块类型和块长度两个字段共7个字节]
                            int blockLength = int.Parse(new string(binReader.ReadChars(4)));
                            if (remainSpace > blockLength) {
                                // 因为块类型和块长度在前面已经获取了，即基础流的位置已经前进了7个字节
                                binReader.BaseStream.Position += blockLength - 7;
                            }
                            else {
                                // 如果该分区块的长度大于当前逻辑记录剩余空间
                                // 先先跳过该剩余空间，设置新的逻辑记录标识块
                                // 之后再进行判断，如果块长度减去剩余空间仍然
                                // 大于一个逻辑记录长度,则需再跳过该逻辑记录并设置新的逻辑记录标识块
                                binReader.BaseStream.Position += remainSpace - 7;// -7的理由跟上面注释一样
                                Helper.SetLogicalRecordIndentBlock(binReader);
                                // 备注0：逻辑记录标识块本身占用了本逻辑记录的8字节的空间
                                if ((blockLength - remainSpace) > (Header.LogicalRecordLength - 8)) {
                                    int times = (blockLength - remainSpace) / (Header.LogicalRecordLength - 8);
                                    for (int num = 0; num < times; num++) {
                                        binReader.BaseStream.Position += (Header.LogicalRecordLength - 8);
                                        Helper.SetLogicalRecordIndentBlock(binReader);
                                    }
                                    binReader.BaseStream.Position += (blockLength - (times * (Header.LogicalRecordLength - 8)) - remainSpace);
                                }
                                else {
                                    binReader.BaseStream.Position += (blockLength - remainSpace);
                                }
                            }
                        }
                    }
                }// end-while
                // 下面这条语句又有点勉强了，出现这种现象的原因是
                // 在跳过不需要的信息的时候，由于逻辑难以控制，所
                // 以为了简化逻辑控制而使程序在读完台站的歌通道之
                // 后多增加了一个逻辑记标识块,为了程序的正确性，在读取下一个台站之前应该移除此标识块
                if (i == (NumChannel - 1)) {
                    Helper.LogicalRecordIndentBlocks.RemoveAt((Helper.LogicalRecordIndentBlocks.Count - 1));
                }
            }// end-for
        }
    }

    public class Channel {
        public string Name          { get; set; }
        public int    InstrumentID  { get; set; }

        public int    SignalRespUnitsID       { get; set; }
        public int    CalibrationInputUnitsID { get; set; }

        public float Latitude       { get; set; }
        public float Longitude      { get; set; }
        public float Elevation      { get; set; }
        public float Depth          { get; set; }
        public float Azimuth        { get; set; }
        public float Dip            { get; set; }
        public int DataFormatID     { get; set; }
        public int DataRecordLength { get; set; }
        public float SampleRate     { get; set; }
        public float MaxClockDrift  { get; set; }
        public string ChannelFlags  { get; set; }
        public DateTime StartDate   { get; set; }
        public DateTime EndDate     { get; set; }
        public char UpdateFlag      { get; set; }

        public List<int> WaveData { get; set; }

        public Channel() {
            WaveData = new List<int>();
        }

        public void ReadChannel(BinaryReader binReader, ControlHeader Header) {
            // 通道标识分区块[052]可能会从一个逻辑记录跨越到另一个逻辑记录
            // 所以在读数据之前，必须对当前逻辑记录的剩余空间进行合理的判断
            int remainSpace = (int)(Helper.LogicalRecordIndentBlocks.Count * Header.LogicalRecordLength - binReader.BaseStream.Position);
            if (remainSpace < 7) {
                binReader.BaseStream.Position += remainSpace;
                Helper.SetLogicalRecordIndentBlock(binReader);
            }
            else {
                // 跳过块类型字段
                binReader.BaseStream.Position += 3;
                int blockLength = int.Parse(new string(binReader.ReadChars(4)));
                #region 剩余空间足够的情况
                if (remainSpace > blockLength) {// 放心地读取本分区块的内容
                    // 跳过位置标识符
                    binReader.BaseStream.Position += 2;
                    Name = new string(binReader.ReadChars(3));
                    // 跳过子通道标识
                    binReader.BaseStream.Position += 4;
                    // 获取仪器标查询ID，通过该ID
                    // 可以在简写字典控制头获得该仪器的详细信息
                    // 具体获取方法可以这样实现
                    // string InstrumentInfo = (from intrument in Header.GenericDicts
                    //                          where intrument.ID == channel.InstrumentID
                    //                          select intrument.Description).Single<string>();
                    InstrumentID = int.Parse(new string(binReader.ReadChars(3)));
                    // 跳过可选注释
                    //binReader.BaseStream.Position += Helper.GetStrFromVariableCharArray(binReader).Length + 1;
                    Helper.GetStrFromVariableCharArray(binReader);
                    // 获取两个单位查询ID，其作用跟上面注释一样
                    SignalRespUnitsID       = int.Parse(new string(binReader.ReadChars(3)));
                    CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                    Latitude  = float.Parse(new string(binReader.ReadChars(10)));
                    Longitude = float.Parse(new string(binReader.ReadChars(11)));
                    Elevation = float.Parse(new string(binReader.ReadChars(7)));
                    Depth     = float.Parse(new string(binReader.ReadChars(5)));
                    Azimuth   = float.Parse(new string(binReader.ReadChars(5)));
                    Dip       = float.Parse(new string(binReader.ReadChars(5)));
                    // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                    DataFormatID     = int.Parse(new string(binReader.ReadChars(4)));
                    DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                    SampleRate       = float.Parse(new string(binReader.ReadChars(10)));
                    MaxClockDrift    = float.Parse(new string(binReader.ReadChars(10)));
                    // 跳过通道注释分区块个数字段
                    binReader.BaseStream.Position += 4;
                    ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                    string str   = Helper.GetStrFromVariableCharArray(binReader);
                    string[] subStr = str.Split(',', ':','.');
                    if (subStr.Length == 7) {
                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                 int.Parse(subStr[1]),
                                                 int.Parse(subStr[2]),
                                                 int.Parse(subStr[3]),
                                                 int.Parse(subStr[4]),
                                                 int.Parse(subStr[5]),
                                                 int.Parse(subStr[6]));
                    }
                    str = Helper.GetStrFromVariableCharArray(binReader);
                    subStr = str.Split(',', ':','.');
                    if (subStr.Length == 7) {
                        EndDate = new DateTime(int.Parse(subStr[0]),
                                               int.Parse(subStr[1]),
                                               int.Parse(subStr[2]),
                                               int.Parse(subStr[3]),
                                               int.Parse(subStr[4]),
                                               int.Parse(subStr[5]),
                                               int.Parse(subStr[6]));
                    }
                    UpdateFlag = binReader.ReadChar();
                }// 结束本逻辑记录剩余空间足以存储完本分区块的情况
                #endregion
                #region 剩余空间不足的情况
                else {
                    remainSpace -= 7;
                    
                    if (remainSpace < 2) { // 跳过位置标识符
                        binReader.BaseStream.Position += remainSpace;
                        Helper.SetLogicalRecordIndentBlock(binReader);
                        binReader.BaseStream.Position += (2 - remainSpace);
                        // 其他的字段就可以放心地读取了，因为本分区块的长度不可能大于一个逻辑记录的长度
                        Name = new string(binReader.ReadChars(3));
                        // 跳过子通道标识
                        binReader.BaseStream.Position += 4;
                        // 获取仪器标查询ID，通过该ID
                        // 可以在简写字典控制头获得该仪器的详细信息
                        // 具体获取方法可以这样实现
                        // string InstrumentInfo = (from intrument in Header.GenericDicts
                        //                          where intrument.ID == channel.InstrumentID
                        //                          select intrument.Description).Single<string>();
                        InstrumentID = int.Parse(new string(binReader.ReadChars(3)));
                        // 跳过可选注释
                        //binReader.BaseStream.Position += Helper.GetStrFromVariableCharArray(binReader).Length + 1;
                        Helper.GetStrFromVariableCharArray(binReader);
                        // 获取两个单位查询ID，其作用跟上面注释一样
                        SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                        CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                        Latitude = float.Parse(new string(binReader.ReadChars(10)));
                        Longitude = float.Parse(new string(binReader.ReadChars(11)));
                        Elevation = float.Parse(new string(binReader.ReadChars(7)));
                        Depth = float.Parse(new string(binReader.ReadChars(5)));
                        Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                        Dip = float.Parse(new string(binReader.ReadChars(5)));
                        // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                        DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                        DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                        SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                        MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                        // 跳过通道注释分区块个数字段
                        binReader.BaseStream.Position += 4;
                        ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                        string str = Helper.GetStrFromVariableCharArray(binReader);
                        string[] subStr = str.Split(',', ':','.');
                        if (subStr.Length == 7) {
                            StartDate = new DateTime(int.Parse(subStr[0]),
                                                     int.Parse(subStr[1]),
                                                     int.Parse(subStr[2]),
                                                     int.Parse(subStr[3]),
                                                     int.Parse(subStr[4]),
                                                     int.Parse(subStr[5]),
                                                     int.Parse(subStr[6]));
                        }
                        str = Helper.GetStrFromVariableCharArray(binReader);
                        subStr = str.Split(',', ':','.');
                        if (subStr.Length == 7) {
                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                   int.Parse(subStr[1]),
                                                   int.Parse(subStr[2]),
                                                   int.Parse(subStr[3]),
                                                   int.Parse(subStr[4]),
                                                   int.Parse(subStr[5]),
                                                   int.Parse(subStr[6]));
                        }
                        UpdateFlag = binReader.ReadChar();
                    }
                    else {
                        remainSpace -= 2;
                        binReader.BaseStream.Position += 2; // 跳过位置标识符

                        if (remainSpace < 3) { // 获取通道标识符
                            Name = Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 3);
                            // 因为该进入一个逻辑记录，所以其他字段放心地读取
                            // 跳过子通道标识
                            binReader.BaseStream.Position += 4;
                            // 获取仪器标查询ID，通过该ID
                            // 可以在简写字典控制头获得该仪器的详细信息
                            // 具体获取方法可以这样实现
                            // string InstrumentInfo = (from intrument in Header.GenericDicts
                            //                          where intrument.ID == channel.InstrumentID
                            //                          select intrument.Description).Single<string>();
                            InstrumentID = int.Parse(new string(binReader.ReadChars(3)));
                            // 跳过可选注释
                            //binReader.BaseStream.Position += Helper.GetStrFromVariableCharArray(binReader).Length + 1;
                            Helper.GetStrFromVariableCharArray(binReader);
                            // 获取两个单位查询ID，其作用跟上面注释一样
                            SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                            CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                            Latitude = float.Parse(new string(binReader.ReadChars(10)));
                            Longitude = float.Parse(new string(binReader.ReadChars(11)));
                            Elevation = float.Parse(new string(binReader.ReadChars(7)));
                            Depth = float.Parse(new string(binReader.ReadChars(5)));
                            Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                            Dip = float.Parse(new string(binReader.ReadChars(5)));
                            // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                            DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                            DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                            SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                            MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                            // 跳过通道注释分区块个数字段
                            binReader.BaseStream.Position += 4;
                            ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                            string str = Helper.GetStrFromVariableCharArray(binReader);
                            string[] subStr = str.Split(',', ':','.');
                            if (subStr.Length == 7) {
                                StartDate = new DateTime(int.Parse(subStr[0]),
                                                         int.Parse(subStr[1]),
                                                         int.Parse(subStr[2]),
                                                         int.Parse(subStr[3]),
                                                         int.Parse(subStr[4]),
                                                         int.Parse(subStr[5]),
                                                         int.Parse(subStr[6]));
                            }
                            str = Helper.GetStrFromVariableCharArray(binReader);
                            subStr = str.Split(',', ':','.');
                            if (subStr.Length == 7) {
                                EndDate = new DateTime(int.Parse(subStr[0]),
                                                       int.Parse(subStr[1]),
                                                       int.Parse(subStr[2]),
                                                       int.Parse(subStr[3]),
                                                       int.Parse(subStr[4]),
                                                       int.Parse(subStr[5]),
                                                       int.Parse(subStr[6]));
                            }
                            UpdateFlag = binReader.ReadChar();
                        }
                        else {
                            remainSpace -= 3;
                            Name = new string(binReader.ReadChars(3));// 获取通道标识符

                            if (remainSpace < 4) { // 跳过子通道标识符
                                binReader.BaseStream.Position += remainSpace;
                                Helper.SetLogicalRecordIndentBlock(binReader);
                                binReader.BaseStream.Position += (4 - remainSpace);
                                //
                                // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                //
                                // 获取仪器标查询ID，通过该ID
                                // 可以在简写字典控制头获得该仪器的详细信息
                                // 具体获取方法可以这样实现
                                // string InstrumentInfo = (from intrument in Header.GenericDicts
                                //                          where intrument.ID == channel.InstrumentID
                                //                          select intrument.Description).Single<string>();
                                InstrumentID = int.Parse(new string(binReader.ReadChars(3)));
                                // 跳过可选注释
                                //binReader.BaseStream.Position += Helper.GetStrFromVariableCharArray(binReader).Length + 1;
                                Helper.GetStrFromVariableCharArray(binReader);
                                // 获取两个单位查询ID，其作用跟上面注释一样
                                SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                Latitude = float.Parse(new string(binReader.ReadChars(10)));
                                Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                Depth = float.Parse(new string(binReader.ReadChars(5)));
                                Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                Dip = float.Parse(new string(binReader.ReadChars(5)));
                                // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                // 跳过通道注释分区块个数字段
                                binReader.BaseStream.Position += 4;
                                ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                string str = Helper.GetStrFromVariableCharArray(binReader);
                                string[] subStr = str.Split(',', ':','.');
                                if (subStr.Length == 7) {
                                    StartDate = new DateTime(int.Parse(subStr[0]),
                                                             int.Parse(subStr[1]),
                                                             int.Parse(subStr[2]),
                                                             int.Parse(subStr[3]),
                                                             int.Parse(subStr[4]),
                                                             int.Parse(subStr[5]),
                                                             int.Parse(subStr[6]));
                                }
                                str = Helper.GetStrFromVariableCharArray(binReader);
                                subStr = str.Split(',', ':','.');
                                if (subStr.Length == 7) {
                                    EndDate = new DateTime(int.Parse(subStr[0]),
                                                           int.Parse(subStr[1]),
                                                           int.Parse(subStr[2]),
                                                           int.Parse(subStr[3]),
                                                           int.Parse(subStr[4]),
                                                           int.Parse(subStr[5]),
                                                           int.Parse(subStr[6]));
                                }
                                UpdateFlag = binReader.ReadChar();
                            }
                            else {
                                remainSpace -= 4;
                                binReader.BaseStream.Position += 4;// 跳过子通道标识符

                                if (remainSpace < 3) { // 获取仪器标识符
                                    InstrumentID = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 3);
                                    //
                                    // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                    //
                                    // 跳过可选注释
                                    //binReader.BaseStream.Position += Helper.GetStrFromVariableCharArray(binReader).Length + 1;
                                    Helper.GetStrFromVariableCharArray(binReader);
                                    // 获取两个单位查询ID，其作用跟上面注释一样
                                    SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                    CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                    Latitude = float.Parse(new string(binReader.ReadChars(10)));
                                    Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                    Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                    Depth = float.Parse(new string(binReader.ReadChars(5)));
                                    Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                    Dip = float.Parse(new string(binReader.ReadChars(5)));
                                    // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                    DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                    DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                    SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                    MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                    // 跳过通道注释分区块个数字段
                                    binReader.BaseStream.Position += 4;
                                    ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                    string str = Helper.GetStrFromVariableCharArray(binReader);
                                    string[] subStr = str.Split(',', ':','.');
                                    if (subStr.Length == 7) {
                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                 int.Parse(subStr[1]),
                                                                 int.Parse(subStr[2]),
                                                                 int.Parse(subStr[3]),
                                                                 int.Parse(subStr[4]),
                                                                 int.Parse(subStr[5]),
                                                                 int.Parse(subStr[6]));
                                    }
                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                    subStr = str.Split(',', ':','.');
                                    if (subStr.Length == 7) {
                                        EndDate = new DateTime(int.Parse(subStr[0]),
                                                               int.Parse(subStr[1]),
                                                               int.Parse(subStr[2]),
                                                               int.Parse(subStr[3]),
                                                               int.Parse(subStr[4]),
                                                               int.Parse(subStr[5]),
                                                               int.Parse(subStr[6]));
                                    }
                                    UpdateFlag = binReader.ReadChar();
                                }
                                else {
                                    remainSpace -= 3;
                                    InstrumentID = int.Parse(new string(binReader.ReadChars(3)));// 获取仪器标识符
                                    // 跳过可选注释
                                    int len = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                    if (remainSpace < len) {
                                        Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                        //
                                        // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                        // 
                                        // 获取两个单位查询ID，其作用跟上面注释一样
                                        SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                        CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                        Latitude = float.Parse(new string(binReader.ReadChars(10)));
                                        Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                        Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                        Depth = float.Parse(new string(binReader.ReadChars(5)));
                                        Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                        Dip = float.Parse(new string(binReader.ReadChars(5)));
                                        // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                        DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                        DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                        SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                        MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                        // 跳过通道注释分区块个数字段
                                        binReader.BaseStream.Position += 4;
                                        ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                        string str = Helper.GetStrFromVariableCharArray(binReader);
                                        string[] subStr = str.Split(',', ':','.');
                                        if (subStr.Length == 7) {
                                            StartDate = new DateTime(int.Parse(subStr[0]),
                                                                     int.Parse(subStr[1]),
                                                                     int.Parse(subStr[2]),
                                                                     int.Parse(subStr[3]),
                                                                     int.Parse(subStr[4]),
                                                                     int.Parse(subStr[5]),
                                                                     int.Parse(subStr[6]));
                                        }
                                        str = Helper.GetStrFromVariableCharArray(binReader);
                                        subStr = str.Split(',', ':','.');
                                        if (subStr.Length == 7) {
                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                   int.Parse(subStr[1]),
                                                                   int.Parse(subStr[2]),
                                                                   int.Parse(subStr[3]),
                                                                   int.Parse(subStr[4]),
                                                                   int.Parse(subStr[5]),
                                                                   int.Parse(subStr[6]));
                                        }
                                        UpdateFlag = binReader.ReadChar();
                                    }
                                    else {
                                        remainSpace -= len;
                                        Helper.GetStrFromVariableCharArray(binReader);

                                        if (remainSpace < 3) { // 获取信号响应单位查询代码
                                            SignalRespUnitsID = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 3);
                                            //
                                            // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                            //
                                            CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));
                                            Latitude = float.Parse(new string(binReader.ReadChars(10)));
                                            Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                            Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                            Depth = float.Parse(new string(binReader.ReadChars(5)));
                                            Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                            Dip = float.Parse(new string(binReader.ReadChars(5)));
                                            // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                            DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                            DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                            SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                            MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                            // 跳过通道注释分区块个数字段
                                            binReader.BaseStream.Position += 4;
                                            ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                            string str = Helper.GetStrFromVariableCharArray(binReader);
                                            string[] subStr = str.Split(',', ':','.');
                                            if (subStr.Length == 7) {
                                                StartDate = new DateTime(int.Parse(subStr[0]),
                                                                         int.Parse(subStr[1]),
                                                                         int.Parse(subStr[2]),
                                                                         int.Parse(subStr[3]),
                                                                         int.Parse(subStr[4]),
                                                                         int.Parse(subStr[5]),
                                                                         int.Parse(subStr[6]));
                                            }
                                            str = Helper.GetStrFromVariableCharArray(binReader);
                                            subStr = str.Split(',', ':','.');
                                            if (subStr.Length == 7) {
                                                EndDate = new DateTime(int.Parse(subStr[0]),
                                                                       int.Parse(subStr[1]),
                                                                       int.Parse(subStr[2]),
                                                                       int.Parse(subStr[3]),
                                                                       int.Parse(subStr[4]),
                                                                       int.Parse(subStr[5]),
                                                                       int.Parse(subStr[6]));
                                            }
                                            UpdateFlag = binReader.ReadChar();
                                        }
                                        else {
                                            remainSpace -= 3;
                                            SignalRespUnitsID = int.Parse(new string(binReader.ReadChars(3)));// 获取信号响应单位查询代码

                                            if (remainSpace < 3) { // 获取标定输入单位查询代码
                                                CalibrationInputUnitsID = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 3);
                                                //
                                                // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                //
                                                Latitude = float.Parse(new string(binReader.ReadChars(10)));
                                                Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                                Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                                Depth = float.Parse(new string(binReader.ReadChars(5)));
                                                Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                                Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                // 跳过通道注释分区块个数字段
                                                binReader.BaseStream.Position += 4;
                                                ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                string str = Helper.GetStrFromVariableCharArray(binReader);
                                                string[] subStr = str.Split(',', ':','.');
                                                if (subStr.Length == 7) {
                                                    StartDate = new DateTime(int.Parse(subStr[0]),
                                                                             int.Parse(subStr[1]),
                                                                             int.Parse(subStr[2]),
                                                                             int.Parse(subStr[3]),
                                                                             int.Parse(subStr[4]),
                                                                             int.Parse(subStr[5]),
                                                                             int.Parse(subStr[6]));
                                                }
                                                str = Helper.GetStrFromVariableCharArray(binReader);
                                                subStr = str.Split(',', ':','.');
                                                if (subStr.Length == 7) {
                                                    EndDate = new DateTime(int.Parse(subStr[0]),
                                                                           int.Parse(subStr[1]),
                                                                           int.Parse(subStr[2]),
                                                                           int.Parse(subStr[3]),
                                                                           int.Parse(subStr[4]),
                                                                           int.Parse(subStr[5]),
                                                                           int.Parse(subStr[6]));
                                                }
                                                UpdateFlag = binReader.ReadChar();
                                            }
                                            else {
                                                remainSpace -= 3;
                                                CalibrationInputUnitsID = int.Parse(new string(binReader.ReadChars(3)));// 获取标定输入单位查询代码

                                                if (remainSpace < 10) { // 获取纬度
                                                    Latitude = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 10);
                                                    //
                                                    // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                    //
                                                    Longitude = float.Parse(new string(binReader.ReadChars(11)));
                                                    Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                                    Depth = float.Parse(new string(binReader.ReadChars(5)));
                                                    Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                                    Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                    // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                    DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                    DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                    SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                    MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                    // 跳过通道注释分区块个数字段
                                                    binReader.BaseStream.Position += 4;
                                                    ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                    string str = Helper.GetStrFromVariableCharArray(binReader);
                                                    string[] subStr = str.Split(',', ':','.');
                                                    if (subStr.Length == 7) {
                                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                 int.Parse(subStr[1]),
                                                                                 int.Parse(subStr[2]),
                                                                                 int.Parse(subStr[3]),
                                                                                 int.Parse(subStr[4]),
                                                                                 int.Parse(subStr[5]),
                                                                                 int.Parse(subStr[6]));
                                                    }
                                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                                    subStr = str.Split(',', ':','.');
                                                    if (subStr.Length == 7) {
                                                        EndDate = new DateTime(int.Parse(subStr[0]),
                                                                               int.Parse(subStr[1]),
                                                                               int.Parse(subStr[2]),
                                                                               int.Parse(subStr[3]),
                                                                               int.Parse(subStr[4]),
                                                                               int.Parse(subStr[5]),
                                                                               int.Parse(subStr[6]));
                                                    }
                                                    UpdateFlag = binReader.ReadChar();
                                                }
                                                else {
                                                    remainSpace -= 10;
                                                    Latitude = float.Parse(new string(binReader.ReadChars(10)));// 获取纬度

                                                    if (remainSpace < 11) { // 获取经度
                                                        Longitude = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 11);
                                                        //
                                                        // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                        //
                                                        Elevation = float.Parse(new string(binReader.ReadChars(7)));
                                                        Depth = float.Parse(new string(binReader.ReadChars(5)));
                                                        Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                                        Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                        // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                        DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                        DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                        SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                        MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                        // 跳过通道注释分区块个数字段
                                                        binReader.BaseStream.Position += 4;
                                                        ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                        string str = Helper.GetStrFromVariableCharArray(binReader);
                                                        string[] subStr = str.Split(',', ':','.');
                                                        if (subStr.Length == 7) {
                                                            StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                     int.Parse(subStr[1]),
                                                                                     int.Parse(subStr[2]),
                                                                                     int.Parse(subStr[3]),
                                                                                     int.Parse(subStr[4]),
                                                                                     int.Parse(subStr[5]),
                                                                                     int.Parse(subStr[6]));
                                                        }
                                                        str = Helper.GetStrFromVariableCharArray(binReader);
                                                        subStr = str.Split(',', ':','.');
                                                        if (subStr.Length == 7) {
                                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                   int.Parse(subStr[1]),
                                                                                   int.Parse(subStr[2]),
                                                                                   int.Parse(subStr[3]),
                                                                                   int.Parse(subStr[4]),
                                                                                   int.Parse(subStr[5]),
                                                                                   int.Parse(subStr[6]));
                                                        }
                                                        UpdateFlag = binReader.ReadChar();
                                                    }
                                                    else {
                                                        remainSpace -= 11;
                                                        Longitude = float.Parse(new string(binReader.ReadChars(11))); // 获取经度

                                                        if (remainSpace < 7) { // 获取海拔
                                                            Elevation = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 7);
                                                            //
                                                            // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                            //
                                                            Depth = float.Parse(new string(binReader.ReadChars(5)));
                                                            Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                                            Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                            // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                            DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                            DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                            SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                            MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                            // 跳过通道注释分区块个数字段
                                                            binReader.BaseStream.Position += 4;
                                                            ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                            string str = Helper.GetStrFromVariableCharArray(binReader);
                                                            string[] subStr = str.Split(',', ':','.');
                                                            if (subStr.Length == 7) {
                                                                StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                         int.Parse(subStr[1]),
                                                                                         int.Parse(subStr[2]),
                                                                                         int.Parse(subStr[3]),
                                                                                         int.Parse(subStr[4]),
                                                                                         int.Parse(subStr[5]),
                                                                                         int.Parse(subStr[6]));
                                                            }
                                                            str = Helper.GetStrFromVariableCharArray(binReader);
                                                            subStr = str.Split(',', ':','.');
                                                            if (subStr.Length == 7) {
                                                                EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                       int.Parse(subStr[1]),
                                                                                       int.Parse(subStr[2]),
                                                                                       int.Parse(subStr[3]),
                                                                                       int.Parse(subStr[4]),
                                                                                       int.Parse(subStr[5]),
                                                                                       int.Parse(subStr[6]));
                                                            }
                                                            UpdateFlag = binReader.ReadChar();
                                                        }
                                                        else {
                                                            remainSpace -= 7;
                                                            Elevation = float.Parse(new string(binReader.ReadChars(7)));// 获取海拔

                                                            if (remainSpace < 5) { // 获取深度
                                                                Depth = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 5);
                                                                //
                                                                // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                //
                                                                Azimuth = float.Parse(new string(binReader.ReadChars(5)));
                                                                Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                                // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                                DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                                DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                                SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                                MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                // 跳过通道注释分区块个数字段
                                                                binReader.BaseStream.Position += 4;
                                                                ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                string[] subStr = str.Split(',', ':','.');
                                                                if (subStr.Length == 7) {
                                                                    StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                             int.Parse(subStr[1]),
                                                                                             int.Parse(subStr[2]),
                                                                                             int.Parse(subStr[3]),
                                                                                             int.Parse(subStr[4]),
                                                                                             int.Parse(subStr[5]),
                                                                                             int.Parse(subStr[6]));
                                                                }
                                                                str = Helper.GetStrFromVariableCharArray(binReader);
                                                                subStr = str.Split(',', ':','.');
                                                                if (subStr.Length == 7) {
                                                                    EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                           int.Parse(subStr[1]),
                                                                                           int.Parse(subStr[2]),
                                                                                           int.Parse(subStr[3]),
                                                                                           int.Parse(subStr[4]),
                                                                                           int.Parse(subStr[5]),
                                                                                           int.Parse(subStr[6]));
                                                                }
                                                                UpdateFlag = binReader.ReadChar();
                                                            }
                                                            else {
                                                                remainSpace -= 5;
                                                                Depth = float.Parse(new string(binReader.ReadChars(5)));// 获取深度

                                                                if (remainSpace < 5) { // 获取方位角
                                                                    Azimuth = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 5);
                                                                    //
                                                                    // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                    //
                                                                    Dip = float.Parse(new string(binReader.ReadChars(5)));
                                                                    // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                                    DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                                    DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                                    SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                                    MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                    // 跳过通道注释分区块个数字段
                                                                    binReader.BaseStream.Position += 4;
                                                                    ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                    string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                    string[] subStr = str.Split(',', ':','.');
                                                                    if (subStr.Length == 7) {
                                                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                 int.Parse(subStr[1]),
                                                                                                 int.Parse(subStr[2]),
                                                                                                 int.Parse(subStr[3]),
                                                                                                 int.Parse(subStr[4]),
                                                                                                 int.Parse(subStr[5]),
                                                                                                 int.Parse(subStr[6]));
                                                                    }
                                                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                                                    subStr = str.Split(',', ':','.');
                                                                    if (subStr.Length == 7) {
                                                                        EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                               int.Parse(subStr[1]),
                                                                                               int.Parse(subStr[2]),
                                                                                               int.Parse(subStr[3]),
                                                                                               int.Parse(subStr[4]),
                                                                                               int.Parse(subStr[5]),
                                                                                               int.Parse(subStr[6]));
                                                                    }
                                                                    UpdateFlag = binReader.ReadChar();
                                                                }
                                                                else {
                                                                    remainSpace -= 5;
                                                                    Azimuth = float.Parse(new string(binReader.ReadChars(5))); // 获取方位角

                                                                    if (remainSpace < 5) { // 获取仰角
                                                                        Dip = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 5);
                                                                        //
                                                                        // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                        //
                                                                        // 获取数据格式查询ID，通过此ID可以得到该数据格式的解码关键字组
                                                                        DataFormatID = int.Parse(new string(binReader.ReadChars(4)));
                                                                        DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                                        SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                                        MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                        // 跳过通道注释分区块个数字段
                                                                        binReader.BaseStream.Position += 4;
                                                                        ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                        string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                        string[] subStr = str.Split(',', ':','.');
                                                                        if (subStr.Length == 7) {
                                                                            StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                     int.Parse(subStr[1]),
                                                                                                     int.Parse(subStr[2]),
                                                                                                     int.Parse(subStr[3]),
                                                                                                     int.Parse(subStr[4]),
                                                                                                     int.Parse(subStr[5]),
                                                                                                     int.Parse(subStr[6]));
                                                                        }
                                                                        str = Helper.GetStrFromVariableCharArray(binReader);
                                                                        subStr = str.Split(',', ':','.');
                                                                        if (subStr.Length == 7) {
                                                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                   int.Parse(subStr[1]),
                                                                                                   int.Parse(subStr[2]),
                                                                                                   int.Parse(subStr[3]),
                                                                                                   int.Parse(subStr[4]),
                                                                                                   int.Parse(subStr[5]),
                                                                                                   int.Parse(subStr[6]));
                                                                        }
                                                                        UpdateFlag = binReader.ReadChar();
                                                                    }
                                                                    else {
                                                                        remainSpace -= 5;
                                                                        Dip = float.Parse(new string(binReader.ReadChars(5)));// 获取仰角

                                                                        if (remainSpace < 4) { // 获取数据格式查询代码
                                                                            DataFormatID = Helper.GetIntFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 4);
                                                                            //
                                                                            // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                            //
                                                                            DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));
                                                                            SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                                            MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                            // 跳过通道注释分区块个数字段
                                                                            binReader.BaseStream.Position += 4;
                                                                            ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                            string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                            string[] subStr = str.Split(',', ':','.');
                                                                            if (subStr.Length == 7) {
                                                                                StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                         int.Parse(subStr[1]),
                                                                                                         int.Parse(subStr[2]),
                                                                                                         int.Parse(subStr[3]),
                                                                                                         int.Parse(subStr[4]),
                                                                                                         int.Parse(subStr[5]),
                                                                                                         int.Parse(subStr[6]));
                                                                            }
                                                                            str = Helper.GetStrFromVariableCharArray(binReader);
                                                                            subStr = str.Split(',', ':','.');
                                                                            if (subStr.Length == 7) {
                                                                                EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                       int.Parse(subStr[1]),
                                                                                                       int.Parse(subStr[2]),
                                                                                                       int.Parse(subStr[3]),
                                                                                                       int.Parse(subStr[4]),
                                                                                                       int.Parse(subStr[5]),
                                                                                                       int.Parse(subStr[6]));
                                                                            }
                                                                            UpdateFlag = binReader.ReadChar();
                                                                        }
                                                                        else {
                                                                            remainSpace -= 4;
                                                                            DataFormatID = int.Parse(new string(binReader.ReadChars(4)));// 获取数据格式查询代码

                                                                            if (remainSpace < 2) { // 获取数据记录长度
                                                                                string str = Helper.GetSStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 2);
                                                                                DataRecordLength = (int)(Math.Pow(2, int.Parse(str)));
                                                                                //
                                                                                // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                //
                                                                                SampleRate = float.Parse(new string(binReader.ReadChars(10)));
                                                                                MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                                // 跳过通道注释分区块个数字段
                                                                                binReader.BaseStream.Position += 4;
                                                                                ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                                str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                string[] subStr = str.Split(',', ':','.');
                                                                                if (subStr.Length == 7) {
                                                                                    StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                             int.Parse(subStr[1]),
                                                                                                             int.Parse(subStr[2]),
                                                                                                             int.Parse(subStr[3]),
                                                                                                             int.Parse(subStr[4]),
                                                                                                             int.Parse(subStr[5]),
                                                                                                             int.Parse(subStr[6]));
                                                                                }
                                                                                str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                subStr = str.Split(',', ':','.');
                                                                                if (subStr.Length == 7) {
                                                                                    EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                           int.Parse(subStr[1]),
                                                                                                           int.Parse(subStr[2]),
                                                                                                           int.Parse(subStr[3]),
                                                                                                           int.Parse(subStr[4]),
                                                                                                           int.Parse(subStr[5]),
                                                                                                           int.Parse(subStr[6]));
                                                                                }
                                                                                UpdateFlag = binReader.ReadChar();
                                                                            }
                                                                            else {
                                                                                remainSpace -= 2;
                                                                                DataRecordLength = (int)(Math.Pow(2, int.Parse(new string(binReader.ReadChars(2)))));// 获取数据记录长度

                                                                                if (remainSpace < 10) { // 获取采样率
                                                                                    SampleRate = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 10);
                                                                                    //
                                                                                    // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                    //
                                                                                    MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));
                                                                                    // 跳过通道注释分区块个数字段
                                                                                    binReader.BaseStream.Position += 4;
                                                                                    ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                                    string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                    string[] subStr = str.Split(',', ':','.');
                                                                                    if (subStr.Length == 7) {
                                                                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                 int.Parse(subStr[1]),
                                                                                                                 int.Parse(subStr[2]),
                                                                                                                 int.Parse(subStr[3]),
                                                                                                                 int.Parse(subStr[4]),
                                                                                                                 int.Parse(subStr[5]),
                                                                                                                 int.Parse(subStr[6]));
                                                                                    }
                                                                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                    subStr = str.Split(',', ':','.');
                                                                                    if (subStr.Length == 7) {
                                                                                        EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                               int.Parse(subStr[1]),
                                                                                                               int.Parse(subStr[2]),
                                                                                                               int.Parse(subStr[3]),
                                                                                                               int.Parse(subStr[4]),
                                                                                                               int.Parse(subStr[5]),
                                                                                                               int.Parse(subStr[6]));
                                                                                    }
                                                                                    UpdateFlag = binReader.ReadChar();
                                                                                }
                                                                                else {
                                                                                    remainSpace -= 10;
                                                                                    SampleRate = float.Parse(new string(binReader.ReadChars(10))); // 获取采样率

                                                                                    if (remainSpace < 10) { // 获取最大时钟漂移
                                                                                        MaxClockDrift = Helper.GetFloatFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace, 10);
                                                                                        //
                                                                                        // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                        //
                                                                                        // 跳过通道注释分区块个数字段
                                                                                        binReader.BaseStream.Position += 4;
                                                                                        ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                                        string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                        string[] subStr = str.Split(',', ':','.');
                                                                                        if (subStr.Length == 7) {
                                                                                            StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                     int.Parse(subStr[1]),
                                                                                                                     int.Parse(subStr[2]),
                                                                                                                     int.Parse(subStr[3]),
                                                                                                                     int.Parse(subStr[4]),
                                                                                                                     int.Parse(subStr[5]),
                                                                                                                     int.Parse(subStr[6]));
                                                                                        }
                                                                                        str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                        subStr = str.Split(',', ':','.');
                                                                                        if (subStr.Length == 7) {
                                                                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                   int.Parse(subStr[1]),
                                                                                                                   int.Parse(subStr[2]),
                                                                                                                   int.Parse(subStr[3]),
                                                                                                                   int.Parse(subStr[4]),
                                                                                                                   int.Parse(subStr[5]),
                                                                                                                   int.Parse(subStr[6]));
                                                                                        }
                                                                                        UpdateFlag = binReader.ReadChar();
                                                                                    }
                                                                                    else {
                                                                                        remainSpace -= 10;
                                                                                        MaxClockDrift = float.Parse(new string(binReader.ReadChars(10)));// 获取最大时钟漂移

                                                                                        if (remainSpace < 4) { // 跳过注释分区块个数
                                                                                            binReader.BaseStream.Position += remainSpace;
                                                                                            Helper.SetLogicalRecordIndentBlock(binReader);
                                                                                            binReader.BaseStream.Position += (4 - remainSpace);
                                                                                            //
                                                                                            // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                            //
                                                                                            ChannelFlags = Helper.GetStrFromVariableCharArray(binReader);
                                                                                            string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                            string[] subStr = str.Split(',', ':','.');
                                                                                            if (subStr.Length == 7) {
                                                                                                StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                         int.Parse(subStr[1]),
                                                                                                                         int.Parse(subStr[2]),
                                                                                                                         int.Parse(subStr[3]),
                                                                                                                         int.Parse(subStr[4]),
                                                                                                                         int.Parse(subStr[5]),
                                                                                                                         int.Parse(subStr[6]));
                                                                                            }
                                                                                            str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                            subStr = str.Split(',', ':','.');
                                                                                            if (subStr.Length == 7) {
                                                                                                EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                       int.Parse(subStr[1]),
                                                                                                                       int.Parse(subStr[2]),
                                                                                                                       int.Parse(subStr[3]),
                                                                                                                       int.Parse(subStr[4]),
                                                                                                                       int.Parse(subStr[5]),
                                                                                                                       int.Parse(subStr[6]));
                                                                                            }
                                                                                            UpdateFlag = binReader.ReadChar();
                                                                                        }
                                                                                        else {
                                                                                            remainSpace -= 4;
                                                                                            binReader.BaseStream.Position += 4;// 跳过注释分区块个数
                                                                                            // 获取通道类型标识符
                                                                                            int cFlagsLength = Helper.GetVariavleCharArrayLength(binReader,remainSpace);
                                                                                            if (remainSpace < cFlagsLength) {
                                                                                                ChannelFlags = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                                                                                //
                                                                                                // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                                //
                                                                                                string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                                string[] subStr = str.Split(',', ':','.');
                                                                                                if (subStr.Length == 7) {
                                                                                                    StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                             int.Parse(subStr[1]),
                                                                                                                             int.Parse(subStr[2]),
                                                                                                                             int.Parse(subStr[3]),
                                                                                                                             int.Parse(subStr[4]),
                                                                                                                             int.Parse(subStr[5]),
                                                                                                                             int.Parse(subStr[6]));
                                                                                                }
                                                                                                str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                                subStr = str.Split(',', ':','.');
                                                                                                if (subStr.Length == 7) {
                                                                                                    EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                           int.Parse(subStr[1]),
                                                                                                                           int.Parse(subStr[2]),
                                                                                                                           int.Parse(subStr[3]),
                                                                                                                           int.Parse(subStr[4]),
                                                                                                                           int.Parse(subStr[5]),
                                                                                                                           int.Parse(subStr[6]));
                                                                                                }
                                                                                                UpdateFlag = binReader.ReadChar();
                                                                                            }
                                                                                            else {
                                                                                                remainSpace -= cFlagsLength;
                                                                                                ChannelFlags = Helper.GetStrFromVariableCharArray(binReader); // 获取通道类型标识符
                                                                                                // 获取开始有效时间
                                                                                                int startDateLength = Helper.GetVariavleCharArrayLength(binReader,remainSpace);
                                                                                                if (remainSpace < startDateLength) {
                                                                                                    string str = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                                                                                    string[] subStr = str.Split(',', ':','.');
                                                                                                    if (subStr.Length == 7) {
                                                                                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                                 int.Parse(subStr[1]),
                                                                                                                                 int.Parse(subStr[2]),
                                                                                                                                 int.Parse(subStr[3]),
                                                                                                                                 int.Parse(subStr[4]),
                                                                                                                                 int.Parse(subStr[5]),
                                                                                                                                 int.Parse(subStr[6]));
                                                                                                    }
                                                                                                    //
                                                                                                    // 因为该进入一个逻辑记录，所以其他字段放心地读取
                                                                                                    //
                                                                                                    str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                                    subStr = str.Split(',', ':','.');
                                                                                                    if (subStr.Length == 7) {
                                                                                                        EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                               int.Parse(subStr[1]),
                                                                                                                               int.Parse(subStr[2]),
                                                                                                                               int.Parse(subStr[3]),
                                                                                                                               int.Parse(subStr[4]),
                                                                                                                               int.Parse(subStr[5]),
                                                                                                                               int.Parse(subStr[6]));
                                                                                                    }
                                                                                                    UpdateFlag = binReader.ReadChar();
                                                                                                }
                                                                                                else {
                                                                                                    remainSpace -= startDateLength;
                                                                                                    string str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                                    string[] subStr = str.Split(',', ':','.');
                                                                                                    if (subStr.Length == 7) {
                                                                                                        StartDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                                 int.Parse(subStr[1]),
                                                                                                                                 int.Parse(subStr[2]),
                                                                                                                                 int.Parse(subStr[3]),
                                                                                                                                 int.Parse(subStr[4]),
                                                                                                                                 int.Parse(subStr[5]),
                                                                                                                                 int.Parse(subStr[6]));
                                                                                                    }
                                                                                                    // 获取有效结束时间[一般为空]
                                                                                                    int endDateLength = Helper.GetVariavleCharArrayLength(binReader, remainSpace);
                                                                                                    if (remainSpace < endDateLength) {
                                                                                                        str = Helper.GetStrFromItAcrossLogicalRecdIndentBlock(binReader, remainSpace);
                                                                                                        subStr = str.Split(',', ':','.');
                                                                                                        if (subStr.Length == 7) {
                                                                                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                                   int.Parse(subStr[1]),
                                                                                                                                   int.Parse(subStr[2]),
                                                                                                                                   int.Parse(subStr[3]),
                                                                                                                                   int.Parse(subStr[4]),
                                                                                                                                   int.Parse(subStr[5]),
                                                                                                                                   int.Parse(subStr[6]));
                                                                                                        }
                                                                                                        UpdateFlag = binReader.ReadChar();
                                                                                                    }
                                                                                                    else {
                                                                                                        remainSpace -= endDateLength;
                                                                                                        str = Helper.GetStrFromVariableCharArray(binReader);
                                                                                                        subStr = str.Split(',', ':','.');
                                                                                                        if (subStr.Length == 7) {
                                                                                                            EndDate = new DateTime(int.Parse(subStr[0]),
                                                                                                                                   int.Parse(subStr[1]),
                                                                                                                                   int.Parse(subStr[2]),
                                                                                                                                   int.Parse(subStr[3]),
                                                                                                                                   int.Parse(subStr[4]),
                                                                                                                                   int.Parse(subStr[5]),
                                                                                                                                   int.Parse(subStr[6]));
                                                                                                        }
                                                                                                        if (remainSpace < 1) {
                                                                                                            // 获取修改标志[其实是零，因为不可能为负]
                                                                                                            Helper.SetLogicalRecordIndentBlock(binReader);
                                                                                                            UpdateFlag = binReader.ReadChar();
                                                                                                        }
                                                                                                        else {
                                                                                                            remainSpace -= 1;
                                                                                                            UpdateFlag = binReader.ReadChar();
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                } // 结束本逻辑记录剩余空间无法存储完本分区块的情况
                #endregion
            }// 结束剩余空间大于7的情况
        }// 结束读取本分区块
    }

    public class TimeSpanConH {
        //Time Span Identifier Blockette
        public char TimeSpanFlag{ get; set; }
        public string EndTime   { get; set; }
        public string BeginTime { get; set; }
        //Hypocenter Information Blockette
        public string OriginTimeOfEvent { get; set; }

        public float Latitude  { get; set; }
        public float Longitude { get; set; }
        public float Depth     { get; set; }
        public float Magnitude { get; set; }

        public string RegionName  { get; set; }

        public List<TimeSeriesInfo> TimeSeries { get; set; }
        public TimeSpanConH() {
            TimeSeries = new List<TimeSeriesInfo>();
        }
        
    }
    public class TimeSeriesInfo {
        // Time Series Index Blockette
        public string StationName { get; set; }
        public string ChannelName { get; set; }
        public string SeriesStartTime   { get; set; }
        public string SeriesEndTime     { get; set; }
        public int FirstDataSeq     { get; set; }
        public int LastDataSeq      { get; set; }
        public string NetworkCode   { get; set; }
    }

    #region 辅助类
    public class StationInfo {
        public string Name      { get; set; }
        public int    Position  { get; set; }
    }

        public class TimeSpanInfo {
            public DateTime BeginOfSpan { get; set; }
            public DateTime EndOfSpan   { get; set; }
            public int      Position    { get; set; }

        }

        public class DataFormat {
            public int          ID   { get; set; }
            public int          Type { get; set; }
            public string       Name { get; set; }
            public List<string> Keys { get; set; }

            public DataFormat() {
                Keys = new List<string>();
            }
        }

        public class Comment {
            public int      ID          { get; set; }
            public char     ClassCode   { get; set; }
            public string   Comments    { get; set; }
            public int      UnitsLevel  { get; set; }
        }

        public class CitedSource {
            public int ID            { get; set; }
            public string AuthorName { get; set; }
            public string Catalog    { get; set; }
            public string Publisher  { get; set; }
        }

        public class GenericDict {
            public int ID             { get; set; }
            public string Description { get; set; }
        }

        public class Unit {
            public int    ID              { get; set; }
            public string UnitName        { get; set; }
            public string UnitDescription { get; set; }
        }
        #endregion
}
